package net.datatables.ajax;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PageImpl<T> {

	private List<T> data;
	private int recordsTotal;
	private int recordsFiltered;

	private Map<String, Object> extInfo;

	public PageImpl(List<T> data, Long recordsTotal) {
		super();
		this.data = data;
		this.recordsTotal = recordsTotal.intValue();
		this.recordsFiltered = recordsTotal.intValue();
	}

	public PageImpl(List<T> data, int recordsTotal) {
		super();
		this.data = data;
		this.recordsTotal = recordsTotal;
		this.recordsFiltered = recordsTotal;
	}

	public PageImpl(List<T> data, int recordsTotal, int recordsFiltered) {
		super();
		this.data = data;
		this.recordsTotal = recordsTotal;
		this.recordsFiltered = recordsFiltered;
	}

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public int getRecordsTotal() {
		return recordsTotal;
	}

	public void setRecordsTotal(int recordsTotal) {
		this.recordsTotal = recordsTotal;
	}

	public int getRecordsFiltered() {
		return recordsFiltered;
	}

	public void setRecordsFiltered(int recordsFiltered) {
		this.recordsFiltered = recordsFiltered;
	}

	public void addExtInfo(String key, Object value) {
		if (extInfo == null) {
			extInfo = new HashMap<String, Object>();
		}
		extInfo.put(key, value);
	}

	public Object getExtInfo(String key) {
		return extInfo.get(key);
	}

}
